package com.accenture.adf.newcodington.module13.sample;

/**
 * 
 * Topic: Error Handling using Try-Catch clause
 * 
 * Instructions:
 * 1. Handle ArrayIndexOutofBounds exception for Array using TRY-CATCH clause
 * 2. Print a message "Count down stopped" irrespective of Exception using FINALLY block
 *
 */

public class TryCatchFinallyTryIt {
	/**
	 * Method to display track count
	 */
	public void showTrackCount() {
		
		int[] intArray = { 10, 9, 8, 7, 6, 4, 3, 2, 1, 0 };
		try
		{
			for(int i = 0; i <= 10; i++)
			{
				System.out.println(intArray[i]);
			}
		}
		catch(ArrayIndexOutOfBoundsException exception) // Handling exception for values exceeding intArrayay size
		{
			System.out.println("Count is exceeding the range..");
		}
		finally // invoked irrespective of exception
		{
		System.out.println("Count down stopped..");
		}
	}

	public static void main(String[] args) {
		// Creating class object
		TryCatchFinallyTryIt obj = new TryCatchFinallyTryIt();
		// Calling method to handle intArrayay Exception
		obj.showTrackCount();
	}

}
